package com.wn.base;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * @FileName: Demo1
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2020/9/27 - 10:52
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
public class Demo1 {

    public static final CountDownLatch countDownLatch = new CountDownLatch(3);

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(Demo1::show);
        Thread thread2 = new Thread(Demo1::show);
        Thread thread3 = new Thread(Demo1::show);
        thread1.start();
        thread2.start();
        thread3.start();
        countDownLatch.await();
        System.out.println("exit");
    }


    public static void show() {
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("show......");
        countDownLatch.countDown();
    }
}
